package org.imlinker.util;

import java.awt.Image;
import java.awt.Toolkit;

import javax.swing.ImageIcon;

/**
 * 保存图片资源.
 */
public class Images extends Object {

	private static Image logo0;

	private static Image logo1;

	private static Image logo2;

	private static Image logo3;

	private static Image logo4;

	private static ImageIcon availableIcon;

	private static ImageIcon awayIcon;

	private static ImageIcon dndIcon;

	private static ImageIcon unavailableIcon;

	private static ImageIcon logoIcon;

	private static ImageIcon logo16px;

	public static ImageIcon getAvailableIcon() {
		if (availableIcon == null) {
			availableIcon = new ImageIcon(Images.class
					.getResource("/resources/available.png"));
			availableIcon.setDescription("available");
		}

		return availableIcon;
	}

	public static ImageIcon getAwayIcon() {
		if (awayIcon == null) {
			awayIcon = new ImageIcon(Images.class
					.getResource("/resources/away.png"));
			awayIcon.setDescription("away");
		}

		return awayIcon;
	}

	public static ImageIcon getDndIcon() {
		if (dndIcon == null) {
			dndIcon = new ImageIcon(Images.class
					.getResource("/resources/dnd.png"));
			dndIcon.setDescription("dnd");
		}

		return dndIcon;
	}

	public static Image getIcon0() {
		if (logo0 == null) {
			logo0 = Toolkit.getDefaultToolkit().createImage(
					Images.class.getResource("/resources/logo0.png"));
		} 

		return logo0;
	}

	public static Image getIcon1() {
		if (logo1 == null) {
			logo1 = Toolkit.getDefaultToolkit().createImage(
					Images.class.getResource("/resources/logo1.png"));
		}

		return logo1;
	}

	public static Image getIcon2() {
		if (logo2 == null) {
			logo2 = Toolkit.getDefaultToolkit().createImage(
					Images.class.getResource("/resources/logo2.png"));
		}

		return logo2;
	}

	public static Image getIcon3() {
		if (logo3 == null) {
			logo3 = Toolkit.getDefaultToolkit().createImage(
					Images.class.getResource("/resources/logo3.png"));
		}

		return logo3;
	}

	public static Image getIcon4() {
		if (logo1 == null) {
			logo4 = Toolkit.getDefaultToolkit().createImage(
					Images.class.getResource("/resources/logo4.png"));
		}

		return logo4;
	}

	public static ImageIcon getIconByDes(String iconDes) {

		if (iconDes.equals("xa")) {
			return Images.getDndIcon();
		} else if (iconDes.equals("unavailable")) {
			return Images.getUnAvailableIcon();
		} else if (iconDes.equals("dnd")) {
			return Images.getDndIcon();
		} else if (iconDes.equals("chat")) {
			return Images.getAvailableIcon();
		} else if (iconDes.equals("away")) {
			return Images.getAwayIcon();
		} else if (iconDes.equals("available")) {
			return Images.getAvailableIcon();
		}

		return null;
	}

	public static Image getLogo() {
		return getIcon1();
	}

	public static ImageIcon getLogo16px() {
		if (logo16px == null) {
			logo16px = new ImageIcon(Images.class
					.getResource("/resources/logo16px.png"));
		}

		return logo16px;
	}

	public static ImageIcon getLogoIcon() {
		if (logoIcon == null) {
			logoIcon = new ImageIcon(Images.class
					.getResource("/resources/logo1.png"));
			logoIcon.setDescription("logo");
		}

		return logoIcon;
	}

	public static ImageIcon getUnAvailableIcon() {
		if (unavailableIcon == null) {
			unavailableIcon = new ImageIcon(Images.class
					.getResource("/resources/unavailable.png"));
			unavailableIcon.setDescription("unavailable");
		}

		return unavailableIcon;
	}

}
